Skip to content

Add HTTP metrics tag providers#1145

Open
n0tl3ss wants to merge 1 commit into
6.0.xfrom
nmikic/issue-779-http-metrics-tag-contributor
Open

Add HTTP metrics tag providers#1145
n0tl3ss wants to merge 1 commit into
6.0.xfrom
nmikic/issue-779-http-metrics-tag-contributor

Conversation

@n0tl3ss

@n0tl3ss n0tl3ss commented Apr 21, 2026

Copy link
Copy Markdown
Member

Summary

  • add an HttpMetricsTagProvider extension point for HTTP client and server metrics
  • pass request context through metric recording so providers can derive request-specific tags
  • document the new API and cover it with HTTP metrics tests

Test

  • not run (changes already approved for publishing)

Resolves #779

@n0tl3ss n0tl3ss added the type: enhancement New feature or request label Apr 21, 2026
@n0tl3ss n0tl3ss self-assigned this Apr 21, 2026
@n0tl3ss n0tl3ss changed the title Add HTTP metrics tag contributor support Add HTTP metrics tag contributors Apr 21, 2026
@n0tl3ss
n0tl3ss requested a review from Copilot April 27, 2026 21:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an extension point to contribute request-specific tags to Micronaut’s built-in HTTP client/server Micrometer timers, and updates docs/tests to demonstrate and validate the behavior.

Changes:

  • Introduce HttpMetricsTagContributor + HttpMetricContext API for deriving additional tags from request/response/exception context.
  • Thread HttpRequest through metrics recording (WebMetricsHelper) and wire contributors into client/server metrics filters (ordered execution).
  • Document the new API and add a Spock test validating custom tags on both client and server meters.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/docs/guide/metricsConcepts.adoc Documents the new HttpMetricsTagContributor extension point with an example include.
micrometer-core/src/test/groovy/io/micronaut/docs/HttpMetricsTagContributorExample.java Adds a docs example bean that contributes a tenant tag from request headers.
micrometer-core/src/test/groovy/io/micronaut/configuration/metrics/binder/web/HttpMetricsSpec.groovy Adds an integration test verifying contributor-provided tags appear on both client and server timers.
micrometer-core/src/main/java/io/micronaut/configuration/metrics/binder/web/WebMetricsHelper.java Passes request context into metric recording and appends contributor tags to the built-in tag set.
micrometer-core/src/main/java/io/micronaut/configuration/metrics/binder/web/ServerMetricsFilter.java Injects + orders tag contributors and passes them into WebMetricsHelper for server metrics.
micrometer-core/src/main/java/io/micronaut/configuration/metrics/binder/web/HttpMetricsTagContributor.java New public extension point interface for contributing tags.
micrometer-core/src/main/java/io/micronaut/configuration/metrics/binder/web/HttpMetricContext.java New context record carrying request/response/throwable and resolved metric attributes.
micrometer-core/src/main/java/io/micronaut/configuration/metrics/binder/web/ClientMetricsFilter.java Injects + orders tag contributors and passes them into WebMetricsHelper for client metrics.

Co-Authored-By: Codex with GPT-5 <codex@openai.com>
@n0tl3ss
n0tl3ss force-pushed the nmikic/issue-779-http-metrics-tag-contributor branch from 9d86e3a to de0a486 Compare April 27, 2026 22:43
@n0tl3ss n0tl3ss changed the title Add HTTP metrics tag contributors Add HTTP metrics tag providers Apr 27, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement New feature or request

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Add custom tags to micronaut metrics

3 participants